// 1. 导入所需模块
import Vue from 'vue'
import VueRouter from 'vue-router'
// 导入所需组件
import MyHome from '@/components/MyHome'
import MyMovie from '@/components/MyMovie'
import MyMusic from '@/components/MyMusic'
import MyAbout from '@/components/MyAbout'
import AboutMe from '@/components/AboutMe'
import AboutYou from '@/components/AboutYou'
import NotFound from '@/components/NotFound'
// 2. 调用 Vue.use() 函数，将 VueRouter 安装为 Vue 的插件
Vue.use(VueRouter)

// 3. 创建路由的实例对象
const router = new VueRouter({
  // 历史模式
  // mode: 'history',
  /*一会要写路由的配置*/
  // 路由规则(hash地址-->要展示的组件，对应关系)
  routes: [
    { path: '/', component: MyHome },
    { path: '/home', component: MyHome },
    { path: '/movie/:id/:name', component: MyMovie },
    { path: '/music', component: MyMusic },
    {
      path: '/about',
      component: MyAbout,
      children: [
        { path: 'me', component: AboutMe },
        { path: 'you', component: AboutYou }
      ]
    },
    { path: '*', component: NotFound }
  ]
})

// 4. 导出路由的实例对象
export default router
